package com.linkage.educloud.ah.bean;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mr'Tang on 2018/12/24.
 */

public class AppDetail implements Serializable{

    private int id;
    private String name;
    private String logo;
    private String url;
    private int type;//1.app,2.html,3,本地页面，4其他
    private int order_num;
    private int inapp_mode;//0.免费， 1单资费，2多资费
    private String inapp_notice;
    private int order_mode;//1订购，2未订购
    private String launcher_path;
    private String launcher_act;
    private int price_type;//1是点播、2.包月
    private int price_me;
    private int price;
    private int source_id;//1 集团应用，2 其他接入应用
    private String author;
    private String provision_url;
    private String authority;
    private int down_num;
    private String intro_imgs;
    private String introduction;
    private String help_url;
    private String desc;
    private String non_responsibility;
    private String version;
    private String uniform_name;
    private String serviceId;
    private String invalid_time;

    public static List<AppDetail> parseFromJsons(JSONArray jsonArray) {
        List<AppDetail> appDetails = new ArrayList<AppDetail>();
        if (jsonArray != null && jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                AppDetail appdetail = parseFromJson(jsonArray
                        .optJSONObject(i));
                if (appdetail != null)
                    appDetails.add(appdetail);
            }
        }
        return appDetails;
    }

    private static AppDetail parseFromJson(JSONObject jsonObj) {
        AppDetail app = new AppDetail();
        app.setId(jsonObj.optInt("id"));
        app.setName(jsonObj.optString("name"));
        app.setLogo(jsonObj.optString("logo"));
        app.setUrl(jsonObj.optString("url"));
        app.setVersion(jsonObj.optString("version"));
        app.setType(jsonObj.optInt("type"));
        app.setOrder_num(jsonObj.optInt("order_num"));
        app.setInapp_mode(jsonObj.optInt("inapp_mode"));
        app.setInapp_notice(jsonObj.optString("inapp_notice"));
        app.setOrder_mode(jsonObj.optInt("order_mode"));
        app.setInvalid_time(jsonObj.optString("invalid_time"));
        app.setLauncher_path(jsonObj.optString("launcher_path"));
        app.setLauncher_act(jsonObj.optString("launcher_act"));
        app.setPrice_type(jsonObj.optInt("price_type"));
        app.setPrice_me(jsonObj.optInt("price_me"));
        app.setPrice(jsonObj.optInt("price"));
        app.setSource_id(jsonObj.optInt("source_id"));
        app.setAuthor(jsonObj.optString("author"));
        app.setProvision_url(jsonObj.optString("provision_url"));
        app.setAuthority(jsonObj.optString("authority"));
        app.setDown_num(jsonObj.optInt("down_num"));
        app.setIntro_imgs(jsonObj.optString("intro_imgs"));
        app.setIntroduction(jsonObj.optString("introduction"));
        app.setHelp_url(jsonObj.optString("help_url"));
        app.setDesc(jsonObj.optString("desc"));
        app.setNon_responsibility(jsonObj.optString("non_responsibility"));
        app.setUniform_name(jsonObj.optString("uniform_name"));
        return app;
    }

    public String getInvalid_time() {
        return invalid_time;
    }

    public void setInvalid_time(String invalid_time) {
        this.invalid_time = invalid_time;
    }

    public String getUniform_name() {
        return uniform_name;
    }

    public void setUniform_name(String uniform_name) {
        this.uniform_name = uniform_name;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public int getOrder_mode() {
        return order_mode;
    }

    public void setOrder_mode(int order_mode) {
        this.order_mode = order_mode;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getOrder_num() {
        return order_num;
    }

    public void setOrder_num(int order_num) {
        this.order_num = order_num;
    }

    public int getInapp_mode() {
        return inapp_mode;
    }

    public void setInapp_mode(int inapp_mode) {
        this.inapp_mode = inapp_mode;
    }

    public String getInapp_notice() {
        return inapp_notice;
    }

    public void setInapp_notice(String inapp_notice) {
        this.inapp_notice = inapp_notice;
    }

    public String getLauncher_path() {
        return launcher_path;
    }

    public void setLauncher_path(String launcher_path) {
        this.launcher_path = launcher_path;
    }

    public String getLauncher_act() {
        return launcher_act;
    }

    public void setLauncher_act(String launcher_act) {
        this.launcher_act = launcher_act;
    }

    public int getPrice_type() {
        return price_type;
    }

    public void setPrice_type(int price_type) {
        this.price_type = price_type;
    }

    public int getPrice_me() {
        return price_me;
    }

    public void setPrice_me(int price_me) {
        this.price_me = price_me;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getSource_id() {
        return source_id;
    }

    public void setSource_id(int source_id) {
        this.source_id = source_id;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getProvision_url() {
        return provision_url;
    }

    public void setProvision_url(String provision_url) {
        this.provision_url = provision_url;
    }

    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public int getDown_num() {
        return down_num;
    }

    public void setDown_num(int down_num) {
        this.down_num = down_num;
    }

    public String getIntro_imgs() {
        return intro_imgs;
    }

    public void setIntro_imgs(String intro_imgs) {
        this.intro_imgs = intro_imgs;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public String getHelp_url() {
        return help_url;
    }

    public void setHelp_url(String help_url) {
        this.help_url = help_url;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getNon_responsibility() {
        return non_responsibility;
    }

    public void setNon_responsibility(String non_responsibility) {
        this.non_responsibility = non_responsibility;
    }
}